<?php

namespace App\Support\CustomForm\Attribute;

use App\Enums\BaseErrorCode;
use App\Exceptions\Custom\ResponseHttpException;
use Exception;

class AttributeMapSupport
{

    /**
     * @param $name
     * @return AttributeSupport
     * @throws Exception
     */
    public function __get($name)
    {
        // TODO: Implement __get() method.
        if (!property_exists($this, $name)) {
            throw new ResponseHttpException(
                BaseErrorCode::$ERROR_OCCURRED,
                null,
                "未配置的表单属性 【{$name}】"
            );
        }
        return $this->{$name};
    }

    /**
     * @param string $name
     * @param AttributeSupport $value
     */
    public function __set(string $name, AttributeSupport $value)
    {
        // TODO: Implement __set() method.
        $this->{$name} = $value;
    }
}
